<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>服务信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="../../../static/images/favicon.ico" th:href="@{/images/favicon.ico}">
    <link rel="stylesheet" href="../../../static/plugin/layui/css/layui.css" th:href="@{/plugin/layui/css/layui.css}"
          media="all"/>
    <link rel="stylesheet" href="../../../static/back_css/public.css" th:href="@{/back_css/public.css}" media="all"/>
    <link rel="stylesheet" href="../../../static/back_css/work_management.css"
          th:href="@{/back_css/work_management.css}" media="all">
    <link rel="stylesheet" href="../../../static/back_css/swiper.css"
          th:href="@{/back_css/swiper.css}" media="all">
</head>
<body>
<div id="main">
    <div class="container">

        <div class="container_content">
            <form class="layui-form">
                <table id="worksList" lay-even class="layui-table" lay-filter="worksList" lay-skin="nob"></table>

                <!--操作-->
                <script type="text/html" id="controls">


                    <span><!-- 超级管理员 -->
                    {{#   if(d.is_PROBTATION==0){                  }}
                    <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="verify">结束此服务器</a>
                    {{#   }else{                                    }}
                        <a class="layui-btn layui-btn-xs layui-btn-warn" lay-event="deprize">开启此服务器</a>
                    {{#         }                                  }}

                    </span>
                </script>
                <input type="hidden" value="0" id="in">
            </form>
        </div>
    </div>
    <input type="hidden" id="Is_Submit" th:value="${Is_Submit}"/>
</div>

<script type="text/javascript" src="../../../static/js/swiper.min.js" th:src="@{/js/swiper.min.js}"></script>
<script type="text/javascript" src="../../../static/plugin/layui/layui.js" th:src="@{/plugin/layui/layui.js}"></script>
<script type="text/javascript">
    window.tplReg = new RegExp("\\[([^\\[\\]]*?)\\]", 'igm'); //i g m是指分别用于指定区分大小写的匹配、全局匹配和多行匹配。

    layui.use(['form', 'layer', 'laydate', 'table', 'laytpl', 'slider'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            slider = layui.slider,
            table = layui.table;
        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        }
        table_render('/getAllProbation');

        //作品列表
        function table_render(url) {
            var ins1 = table.render({
                elem: '#worksList',
                url: url,
                cellMinWidth: 95,
                page: true,
                height: "",
                even: true, //开启隔行背景
                limit: 10,
                limits: [10, 15, 20, 25, 30, 35, 40, 45, 50],
                id: "worksListTable",
                cols: [
                    [
                        {type: "checkbox", fixed: "left", hide: true, width: 45},
                        {field: 'id',unresize: true,  title: '编号', width: 100},
                        {field: 'admin',unresize: true, title: '主账号', width: 200},
                        {field: 'server_ID',unresize: true, title: '服务器编号', width: 200},
                        {field: 'start_TIME',unresize: true, title: '创建时间', width: 200},
                        {
                            field: 'is_PROBTATION',
                            title: '服务状态',
                            unresize: true,
                            align: 'center',
                            sort: true,
                            minWidth: 105,
                            templet: function (d) {
                                if(d.is_PROBTATION == "0"){
                                    return "正在使用";
                                }else if(d.is_PROBTATION == "1"){
                                    return "试用已结束";
                                }
                                //return d.work_TYPE == "0" ? "视频" : "音频";
                            }

                        },
                        {title: '操作',unresize: true, width: 440, templet: '#controls', fixed: "right", align: "center"}
                    ]
                ],
                parseData: function(res){
                    //res 即为原始返回的数据
                    console.log("返回数据>",res);
                    var a = res.IS_LOCAL;
                    $("#in").val(a);
                    exportData = res.data
                }
            });
        }


        //列表操作
        table.on('tool(worksList)', function (obj) {
            //.log("obj", obj)
            var layEvent = obj.event,
                data = obj.data;

            if (layEvent === 'verify') { //编辑

                layer.confirm('确定结束此账号的使用？', {icon: 3, title: '提示信息'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: '/updateProbtation',
                        async: false,
                        type: "POST",
                        data: {
                            SERVER_ID:data.server_ID,
                            ADMIN:data.admin,
                            IS_PROBTATION:1
                        },
                        success: function (data) {
                            $(".layui-laypage-btn").click();
                            // table_render('/getAllProbation');
                        }
                    })
                });
            } else if (layEvent === "deprize") {
                layer.confirm('确定开启使用此账号？', {icon: 3, title: '提示信息'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: '/updateProbtation',
                        async: false,
                        type: "POST",
                        data: {
                            SERVER_ID:data.server_ID,
                            ADMIN:data.admin,
                            IS_PROBTATION:0
                        },
                        success: function (data) {
                            $(".layui-laypage-btn").click();
                            // table_render('/getAllProbation');
                        }
                    })
                });
            }
        });

    });

</script>
</body>
</html>